package Classe;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Observable;

public class ReservationItem extends Observable{
	
	private Date m_dateDebut;
	private Date m_dateFin;
	private int m_quantite;
	private ChambreCategorie.CategorieChambre m_chambreCategorie;
	public int m_quantiteSejour;
	public Date getDateDebut()
	{
		return m_dateDebut;		
	}
	
	public Date getDateFin()
	{
		return m_dateFin;		
	}	
	public boolean canAugmenteQuantiteSejour()
	{
		return m_quantiteSejour < m_quantite;
	}
	public void augmenteQuantiteSejour()
	{
		if(canAugmenteQuantiteSejour())
			m_quantiteSejour++;
	}
	public int getQuantiteSejour()
	{
		return m_quantiteSejour;
	}
	public int getQuantite()
	{
		return m_quantite;		
	}
	
	public ChambreCategorie.CategorieChambre getChambreCategorie()
	{
		return m_chambreCategorie;		
	}
		
	public ReservationItem(Date pDebut, Date pFin, int pQuantite, ChambreCategorie.CategorieChambre pType)
	{
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		try {
			pDebut = formatter.parse(formatter.format(pDebut));
			pFin = formatter.parse(formatter.format(pFin));
		} catch (ParseException e) {			
		} 
		m_dateDebut = pDebut;
		m_dateFin = pFin;
		m_quantite = pQuantite;
		m_chambreCategorie = pType;
		m_quantiteSejour = 0;
	}
	public void DeclancherObserver()
	{
		setChanged();
		notifyObservers();
	}
}
